const express = require("express");
const { addBlogTypeService, findAllBlogTypeService, findOneBlogTypeService, updateBlogTypeService, deleteBlogTypeService } = require("../service/blogTypeService");
const router = express.Router();

// 获取博客分类
router.get("/", async function(req, res, next) {
  res.send(await findAllBlogTypeService())
})

// 获取指定一个博客分类
router.get("/:id", async function(req, res, next) {
  res.send(await findOneBlogTypeService(req.params.id))
})

// 添加一个博客分类
router.post("/", async function(req, res, next) {
  res.send(await addBlogTypeService(req.body))
})

// 修改一个博客分类
router.put("/:id", async function(req, res, next) {
  res.send(await updateBlogTypeService(req.params.id, req.body))
})

// 删除一个博客分类
router.delete("/:id", async function(req, res, next) {
  res.send(await deleteBlogTypeService(req.params.id))
})


module.exports = router;